﻿@model IEnumerable<SAKS.Models.Award>
@{
    ViewBag.Title = "科技成果获奖情况";
    Layout = "~/Views/Achievement/_Layout.cshtml";
}

<h2>获奖情况</h2>
@if (HttpContext.Current.User.IsInRole("Editor"))
{ 
<div class="col_header">
<a href="/Achievement/AddAward/@ViewBag.AchievementId">添加获奖信息</a>
</div>
}
<hr />
<input type="hidden" id="AchiId" value="@ViewBag.AchievementId" />
@if (Model.Count() == 0)
{
    <p>没有获奖信息</p>
}
else
{
    foreach (var m in Model)
    { 
        <div class="display-box" id="@m.Id">
        @if (HttpContext.Current.User.IsInRole("Editor"))
        { 
            <a class="removeAward" href="#" awardId="@m.Id">移除</a>
        }
        <div class="display-label">
            <label for="Name">奖项名称</label>
        </div>
        <div class="display-field">
            @m.Name
        </div>

        <div class="display-label">
            <label for="Year">年份</label>
        </div>
        <div class="display-field">
            @(m.Year.Year + "-" + m.Year.Month)
        </div>

        <div class="display-label">
            <label for="AwardType">奖项类型</label>
        </div>
        <div class="display-field">
            @m.AwardType
        </div>

        <div class="display-label">
            <label for="AwardLevel">奖项等级</label>
        </div>
        <div class="display-field">
            @m.AwardLevel
        </div>
         <hr />    
        </div>
       
    }
}
<script type="text/javascript">
    $(function () {
        $(".removeAward").click(function () {
            if (confirm("你确定要移除这条信息吗") == true) {
                var awardid = $(this).attr("awardId");
                $.post(
                    "/Achievement/RemoveAward",
                    { achiId: $("#AchiId").get(0).value, awardId: awardid },
                    function (data) {
                        $("#" + data.AwardId).fadeOut();

                    }

                );
            }
        });
    });
</script>